package com.satan.juc.demo13;

import java.util.concurrent.locks.LockSupport;

/**
 * @Author: Demon
 * @Date: 2024/3/29 16:49
 * @Description:这个例子中，线程将会被park方法阻塞，直到主线程调用unpark方法。
 **/
public class ParkDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            System.out.println("Thread is going to park.");
            LockSupport.park();
            System.out.println("Thread is unparked.");
        });
        LockSupport.unpark(thread);
        thread.start();
        Thread.sleep(1000);
        LockSupport.unpark(thread);

    }
}
